[3.7] bpo-39389: gzip: fix compression level metadata (GH-18077)#18101
Conversation
As described in RFC 1952, section 2.3.1, the XFL (eXtra FLags) byte of a gzip member header should indicate whether the DEFLATE algorithm was tuned for speed or compression ratio. Prior to this patch, archives emitted by the `gzip` module always indicated maximum compression. (cherry picked from commit eab3b3f) Co-authored-by: William Chargin <wchargin@gmail.com>
|
@wchargin and @serhiy-storchaka: Status check is done, and it's a failure ❌ . |
1 similar comment
|
@wchargin and @serhiy-storchaka: Status check is done, and it's a failure ❌ . |
|
@serhiy-storchaka The CI test run failed but, before restarting it by creating a new backport, should we really be backporting this to 3.7 at this stage? Is there a real problem that 3.7 users are encountering or do we risk introducing a needless change in behavior? |
|
It’s a real problem that I’m encountering (hence the patch). I can work |
|
(The CI failures look legit; the constants used were added in #9833, |
|
Ping |
|
@ned-deily: We should apply the following patch to the backport: From 2f951ad470973c7576dda0659d647cece4d77b50 Mon Sep 17 00:00:00 2001
From: William Chargin <wchargin@gmail.com>
Date: Tue, 3 Mar 2020 19:08:37 -0800
Subject: [PATCH] [bpo-39389](https://bugs.python.org/issue39389): add constants for 3.7 backport
Backport: <https://github.com/python/cpython/pull/18101>
---
Lib/gzip.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Lib/gzip.py b/Lib/gzip.py
index 0b039d569d..e59b454814 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -17,6 +17,11 @@ FTEXT, FHCRC, FEXTRA, FNAME, FCOMMENT = 1, 2, 4, 8, 16
READ, WRITE = 1, 2
+_COMPRESS_LEVEL_FAST = 1
+_COMPRESS_LEVEL_TRADEOFF = 6
+_COMPRESS_LEVEL_BEST = 9
+
+
def open(filename, mode="rb", compresslevel=9,
encoding=None, errors=None, newline=None):
"""Open a gzip-compressed file in binary or text mode.
--
2.23.0.rc1.1.g9eb78f1760
I can repro the test failure before this patch, and it passes after this But I don’t have write access to |
|
Awesome; thank you! :-) |
This change implements a fix to compression in gzip tool that CPython applied per https://bugs.python.org/issue39389. It uses proper XFL value in gzip header per https://tools.ietf.org/html/rfc1952, section 2.3.1. Refs: * python/cpython#18077 (CPython 3.9.0+) * python/cpython#18100 (CPython 3.8.2+) * python/cpython#18101 (CPython 3.7.7+) Fixes #1849
This change implements a fix to compression in gzip tool that CPython applied per https://bugs.python.org/issue39389. It uses proper XFL value in gzip header per https://tools.ietf.org/html/rfc1952, section 2.3.1. Refs: * python/cpython#18077 (CPython 3.9.0+) * python/cpython#18100 (CPython 3.8.2+) * python/cpython#18101 (CPython 3.7.7+) Fixes #1849 (cherry picked from commit 3925ae9)
As described in RFC 1952, section 2.3.1, the XFL (eXtra FLags) byte of a
gzip member header should indicate whether the DEFLATE algorithm was
tuned for speed or compression ratio. Prior to this patch, archives
emitted by the
gzipmodule always indicated maximum compression.(cherry picked from commit eab3b3f)
Co-authored-by: William Chargin wchargin@gmail.com
https://bugs.python.org/issue39389